package com.randi.web.config;

import com.randi.common.config.Swagger2Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.*;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;


/**
 * @author ziye
 */
@EnableSwagger2
@Configuration(value = "webSwaggerConfig")
public class SwaggerConfig extends Swagger2Config {

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("后端业务API接口文档")
                .contact(new Contact("", "", ""))
                .description("兰迪管理系统接口文档")
                .version("1.0")
                .build();
    }

    @Bean("createRestApi")
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("后端业务")
                .enable(swaggerEnable)
                .apiInfo(this.apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.randi.web"))
//                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
                .paths(PathSelectors.any())
                .build()
                .securitySchemes(securitySchemes())
                .securityContexts(securityContexts())
                .pathMapping(pathMapping);
    }


}
